package com.example.jinzproduct.server.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.plugins.Page;
import com.example.commons.entity.CertificateNewsDO;
import com.example.commons.utils.EhCacheUtil;
import com.example.jinzproduct.dao.CertificateNewsDao;
import com.example.jinzproduct.server.CertificateNewsService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 
 * <pre>
 * 证书信息
 * </pre>
 * <small> 2020-02-24 21:00:12 | lance</small>
 */
@Service
public class CertificateNewsServiceImpl extends ServiceImpl<CertificateNewsDao, CertificateNewsDO> implements CertificateNewsService {

    @Override
    public Page<Map<String,Object>> selectListPage(int current, int number) {

        // 新建分页
        Page<Map<String,Object>> page = new Page<Map<String,Object>>(current, number);

        List<Map<String, Object>> jsonArray = (List<Map<String, Object>>) EhCacheUtil.get("selCertificateList");
        if(jsonArray==null){
            List<Map<String, Object>> list=  this.baseMapper.dyGetUserList(page);
            //将list1存到缓存中
            EhCacheUtil.put("selCertificateList" , list);
            // 根据情况，返回分页结果
            return  page.setRecords(list);
        }else {
            return  page.setRecords(jsonArray);
        }

    }

    @Override
    public Page<CertificateNewsDO> selectListPages(int current, int number) {

        // 新建分页
        Page<CertificateNewsDO> page = new Page<CertificateNewsDO>(current, number);
        return page.setRecords(this.baseMapper.dyGetUserLists(page));
    }

    @Override
    public Page<CertificateNewsDO> selectListPagesFormal(int current, int number) {
        Page<CertificateNewsDO> page = new Page<CertificateNewsDO>(current, number);
        return page.setRecords(this.baseMapper.dyGetUserListsFormal(page));
    }

    @Override
    public List<Map<Object,Object>> selByNotGrade() {
        return baseMapper.selByNotGrade();
    }
    @Override
    public List<Map<Object,Object>> selByProfileId(){
        return baseMapper.selByProfileId();
    }
    @Override
    public List<Map<Object,Object>> selByProfile(){
        return baseMapper.selByProfile();
    }

    @Override
    public List<Map<Object,Object>> selByNewId(){
        return baseMapper.selByNewId();
    }

    @Override
    public Map<Object,Object> selByNewName(Long newsId){
        return baseMapper.selByNewName(newsId);
    }

}
